#pragma once
#include "Material.h"

#include <utility>
#include "Texture2D.h"
#include "Path.h"
#include "ShaderProgram.h"

class FShadowLightMaterial final
	: public FMaterial
{
public:

	std::filesystem::path GetVsSrcPath() const override
	{
		return FPath::BuildShaderPath("MultipleLights/shaderShadow.vs");
	}

	std::filesystem::path GetFsSrcPath() const override
	{
		return FPath::BuildShaderPath("MultipleLights/shaderShadow.fs");
	}

private:

	std::shared_ptr<FTexture2D> TextureDiffuse;

	std::shared_ptr<FTexture2D> TextureShadowMap;

public:

	bool InitWithShadowMap(std::shared_ptr<FTexture2D> InTextureShadowMap) 
	{
		InitShaderWayType = EInitShaderWayType::File;
		
		TextureShadowMap = std::move(InTextureShadowMap);

		if (!this->Init())
		{
			return false;
		}

		FTextureBuild Build;
		TextureDiffuse = Build.Build(FPath::BuildImgPath("container2.png"), true);

		Shader->Use();
		Shader->SetLightingModel(ELightingModel::DiffuseShininess);
		Shader->SetFloat("material.shininess", 32.0f);
		Shader->SetInt("material.diffuse", 0);
		Shader->SetInt("shadowMap", 1);

		return true;
	}

	virtual void Use() override
	{
		FMaterial::Use();

		TextureDiffuse->BindTextureUnit(0);
		TextureShadowMap->BindTextureUnit(1);
	}
};

